#!/user/local/python/bin/python
# coding=utf-8
# /***************************************************************************************************/
# /*Script Name: checkLoadTemplate.py           	 												 */								    		    */
# /*Create Date: 2020-06-02                                                                          */
# /*Script Developed By: sjc                                                                         */
# /*Script Use : checkLoad temlate                                                                   */
# /*******************************Import Modules******************************************************/

import sys
import os

# from hdfs.client import Client

'''
    检测文件内容
'''


def getHdfs():
    global _fs
    if _fs is None:
        # activeNode = HdfsUtil.getActiveNode()
        # if activeNode is not None and len(activeNode) > 0:
        # Config.NAME_NODE_ADDR = activeNode
        _fs = pyhdfs.connect('zjhydsz23', 8020)
    return _fs


def openFile(hdfs_path):
    fs = getHdfs()
    with pyhdfs.open(fs, hdfs_path) as lines:
        for line in lines:
            print(line)


if __name__ == '__main__':

    _outputhdfsDir = "/home/edw/MD5/a.log"

    x = 'hadoop fs -cat /user/edw/tmp/ADP2_DEMAND_MANAGE_20201001.dat'

    with open(_outputhdfsDir) as file_obj:
        lines = file_obj.readlines()

    for line in lines:
        if "成功" in line.rstrip():
            print("成功")
        else:
            print("失败")
        break

    with hdfs.open('/user/edw/tmp/ADP2_DEMAND_MANAGE_20201001.dat') as f:
        for line in f:
            print(line)
    '''
    # read_hdfs_file()
    # 
    # class Process_Data_Hdfs():
    # 
    #     def __init__(self):
    #         self.client = Client("http://172.26.135.195:50070")
    #         self.filename = "/user/edw/tmp/ADP2_DEMAND_MANAGE_20201001.dat"
    '''
